<template>
  <view class="container">
    <mumu-get-qrcode
      :isUseTorch="false"
      @success="qrcodeSucess"
      @error="qrcodeError"
    >
      <template v-slot:option>
        <view class="track font-s16" @click="goRedempt" v-if="type == 1"
          >核销码核销</view
        >
      </template>
    </mumu-get-qrcode>
  </view>
</template>

<script>
import mumuGetQrcode from '../../uni_modules/mumu-getQrcode/mumu-getQrcode.vue'
export default {
	components: {
		mumuGetQrcode
	},
	data() {
		return {
			type: ''
		}
	},
	onLoad(option) {
		this.type = 1;
	},
	methods: {
	  qrcodeSucess(data) {
	    // 处理扫码成功的逻辑
			// this.$toast(data)
			uni.redirectTo({
			  url: data // 目标页面的路径
			});
	  },
	  qrcodeError(err) {
	    // 处理扫码失败的逻辑
			this.$toast('扫描失败')
	  },
		/** 核销码核销 */
		goRedempt() {
			uni.redirectTo({
			  url: '/pages_sh/orderCode/redempt' // 目标页面的路径
			});
		}
	}
}
</script>

<style lang="less" scoped>
.track {
  position: absolute;
  bottom: -290rpx;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 20rpx;
  border-radius: 20rpx;
}
</style>
